package com.peace.hospital.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.peace.hospital.entity.hospitalization.entity.Doctoradvice;
import com.peace.hospital.entity.hospitalization.entity.People;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xie
 * @since 2019-11-06
 */
@Mapper
public interface DoctoradviceMapper extends BaseMapper<Doctoradvice> {

    /**
     * 添加医嘱
     * @param da
     * @return
     */
    @Insert({" INSERT INTO hospitalization.doctoradvice(staid,pid,doccontent,startdate,terminationdate,advstate)" +
            "VALUES(#{staid},#{pid},#{doccontent},#{startdate},#{terminationdate},1)"})
     int insertDoctorAdvice(Doctoradvice da);

    /**
     * 删除医嘱
     * @param da
     * @return
     */
    @Delete({"update hospitalization.doctoradvice set advstate = 0 WHERE da=#{da}"})
    int deleteDoctorAdvice(Integer da);


    @Select({"select * from hospitalization.doctoradvice  where pid = #{pid} and advstate = 1"})
    Doctoradvice selectAdvice(People people);
}
